<template>
  <div id="message">
    <div class="user_msg">
      <div class="m_pic">
        <img src="../assets/image/u_pic.jpg" alt />
      </div>
      <div class="m_info">
        <p class="info_name">
          TES&nbsp;Hanser
          <span class="info_lv">Lv.150</span>
        </p>
        <p class="info_address">峡谷之巅</p>
        <p class="play_num">
          总共进行了
          <span>12312</span>
          次对局
        </p>
      </div>
      <div class="m_honor">
        <ul class="honor_icon clearfix">
          <li>
            <span class="triplekill">264次</span>
            <p>三杀</p>
          </li>
          <li>
            <span class="quadrakill">164次</span>
            <p>四杀</p>
          </li>
          <li>
            <span class="pentakill">64次</span>
            <p>五杀</p>
          </li>
          <li>
            <span class="godlike">124次</span>
            <p style="width:100px">超神</p>
          </li>
          <li>
            <span class="mvp">964次</span>
            <p>MVP</p>
          </li>
        </ul>
      </div>
    </div>
    <div class="user_chats">
      <div class="rank">
        <h1>本赛季荣誉</h1>
        <img src="../assets/image/challenger_1.png" />
        <p class="rank_title">最强王者</p>
        <div class="sl">
          <div class="sl_txt clearfix">
            <span class="txt_1">单双排</span>
            <span class="txt_2">总场次{{win+lose}}</span>
            <span class="txt_3">
              <span style="font-weight:600;margin-right:10px">1125</span>胜点
            </span>
          </div>
          <div class="sl_out">
            <span class="sl_num">胜率&nbsp;{{winrateNum}}%</span>
            <div class="sl_in" :style="{width:winrateNum+'%'}"></div>
          </div>
          <div class="wol clearfix">
            <span class="sl_win">{{win}}胜</span>
            <span class="sl_lose">{{lose}}负</span>
          </div>
        </div>
      </div>
      <div class="radar" id="radar_div"></div>
      <div class="kda" id="kda_div"></div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      win: 235,
      lose: 110,
    };
  },
  computed: {
    winrateNum: function () {
      return ((this.win / (this.win + this.lose)) * 100).toFixed(2);
    },
  },
  methods: {
    radarDraw() {
      let myRadar = this.$echarts.init(document.getElementById("radar_div"));
      myRadar.setOption({
        tooltip: {},
        legend: { enabled: false },
        radar: {
          name: {
            textStyle: {
              color: "black",
              fontSize: "12",
            },
          },
          indicator: [
            { name: "金钱", max: 100 },
            { name: "击杀", max: 100 },
            { name: "助攻", max: 100 },
            { name: "存活", max: 100 },
            { name: "承伤", max: 100 },
            { name: "物理", max: 100 },
            { name: "魔法", max: 100 },
          ],
          radius: 80,
        },
        series: [
          {
            name: "数据雷达图",
            type: "radar",
            symbol: "none",
            lineStyle: {
              color: "#4971eb",
              width: 2,
            },
            areaStyle: {
              color: "#4971eb",
              opacity: 0.5,
              emphasis: {
                color: "#4971eb",
                opacity: 1,
              },
            },
            data: [
              {
                value: [75, 92, 100, 76, 23, 87, 77],
              },
            ],
          },
        ],
      });
    },
    lineDraw() {
      let myLine = this.$echarts.init(document.getElementById("kda_div"));
      myLine.setOption({
        title: {
          text: "召唤师游戏模式",
          left: "center",
          top: "18px",
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)",
        },
        series: [
          {
            name: "游戏模式",
            type: "pie",
            radius: "50%",
            center: ["50%", "60%"],
            data: [
              { value: 335, name: "云顶之弈" },
              { value: 310, name: "轮换模式" },
              { value: 234, name: "匹配模式" },
              { value: 135, name: "极地大乱斗" },
              { value: 1548, name: "单双排位" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      });
    },
  },
  mounted() {
    this.radarDraw();
    this.lineDraw();
  },
};
</script>

<style lang="less" scoped>
#message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  .user_msg {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    .m_pic {
      width: 96px;
      height: 96px;
      border-radius: 50%;
      overflow: hidden;
      border: 5px solid rgba(89, 0, 114, 0.7);
      img {
        width: inherit;
        height: inherit;
      }
    }
    .m_info {
      margin-left: 20px;
      .info_name {
        font-weight: 600;
        font-size: 26px;
        .info_lv {
          font-size: 16px;
          color: #0baac0;
        }
      }
      .info_address {
        margin: 16px 0 10px 0;
        font-size: 16px;
      }
      .play_num {
        font-size: 14px;
        span {
          color: rgb(41, 171, 251);
          font-weight: bold;
        }
      }
    }
    .m_honor {
      margin-left: 20px;
      .honor_icon {
        li {
          width: 79px;
          height: 126px;
          float: left;
          text-align: center;
          margin-left: 62px;
          span {
            display: block;
            height: 94px;
            padding-top: 70px;
            color: #fff;
            background-image: url(../assets/image/game-info-spr.png);
            &.triplekill {
              background-position: 288px -97px;
            }
            &.quadrakill {
              background-position: 204px -97px;
            }
            &.pentakill {
              background-position: 372px -97px;
            }
            &.godlike {
              width: 100px;
              background-position: 1182px -97px;
            }
            &.mvp {
              background-position: 456px -97px;
            }
          }
          p {
            font-size: 14px;
            margin-top: 11px;
            color: #aaa;
          }
        }
      }
    }
  }
  .user_chats {
    margin-top: 20px;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 33.33%);
    .rank {
      display: flex;
      flex-direction: column;
      align-items: center;
      h1 {
        font-size: 20px;
        letter-spacing: 2px;
        margin: 20px;
      }
      img {
        margin-top: 10px;
        width: 96px;
        height: 96px;
      }
      .rank_title {
        color: #4971eb;
        font-weight: 600;
      }
      .sl {
        width: 280px;
        height: 100px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        .sl_out {
          width: 280px;
          height: 40px;
          background-color: #d6e9ff;
          text-align: center;
          position: relative;
          .sl_num {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            color: #fff;
          }
          .sl_in {
            height: 100%;
            line-height: 40px;
            background-color: #0891f7;
          }
        }
      }
      .sl_txt {
        font-size: 14px;
        margin: 6px 0;
        color: #333;
        .txt_1 {
          float: left;
        }
        .txt_2 {
          font-size: 12px;
          color: #999fad;
          padding-left: 12px;
        }
        .txt_3 {
          float: right;
        }
      }
      .wol {
        font-size: 12px;
        color: #4971eb;
        margin-top: 8px;
        .sl_win {
          float: left;
        }
        .sl_lose {
          float: right;
        }
      }
    }
    & > div {
      height: 300px;
      margin: 0 10px;
      box-shadow: 2px 6px 12px #999fad;
    }
    & > div:hover {
      transform: scale(1.09);
      transition-duration: 0.5s;
    }
  }
}
</style>